You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by jaydoane <gi...@git.apache.org> on 2016/07/16 00:12:28 UTC

[GitHub] couchdb-couch issue #185: 3061 adaptive header search

Github user jaydoane commented on the issue:

    https://github.com/apache/couchdb-couch/pull/185
  
    I've been testing with this repl command:
    ```erlang
    _time_find_header = fun(File, Algorithm) when is_list(File) ->
        FileSize = filelib:file_size(File),
        {ok, Fd} = file:open(File, [raw, read, binary]),
        {Time, Result} = case Algorithm of
            current ->
                timer:tc(couch_file,find_header,[Fd, FileSize div 4096]);
            default ->
                timer:tc(couch_file,find_last_header,[Fd, FileSize]);
            adaptive ->
                ok = config:set_integer("couchdb", "chunk_max_size", 4096*4096),
                ok = config:set_integer("couchdb", "chunk_exponent_base", 2),
                Res = timer:tc(couch_file,find_last_header,[Fd, FileSize]),
                ok = config:delete("couchdb", "chunk_max_size"),
                ok = config:delete("couchdb", "chunk_exponent_base"),
                Res
        end,
        ok = file:close(Fd),
        case Result of 
            {ok, HeaderBin} ->
                {Time, binary_to_term(HeaderBin)};
            _ ->
                {Time, Result}
        end
    end.
    ```
    and use it like so:
    ```erlang
    (node1@127.0.0.1)78> _time_find_header("/Users/jay/proj/ibm/sample-data/foo.couch", current).
    {255,
     {db_header,6,0,0,nil,nil,nil,0,nil,nil,1000,
                <<"1ca5e7003114d27fa1dcfff52b10163f">>,
                [{'node1@127.0.0.1',0}],
                0}}
    (node1@127.0.0.1)79> _time_find_header("/Users/jay/proj/ibm/sample-data/foo.couch", default).
    {119,
     {db_header,6,0,0,nil,nil,nil,0,nil,nil,1000,
                <<"1ca5e7003114d27fa1dcfff52b10163f">>,
                [{'node1@127.0.0.1',0}],
                0}}
    (node1@127.0.0.1)80> _time_find_header("/Users/jay/proj/ibm/sample-data/foo.couch", adaptive).
    {138,
     {db_header,6,0,0,nil,nil,nil,0,nil,nil,1000,
                <<"1ca5e7003114d27fa1dcfff52b10163f">>,
                [{'node1@127.0.0.1',0}],
                0}}
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---