gettext icon indicating copy to clipboard operation
gettext copied to clipboard

Optimize phrase access speed via public ETS

Open seriyps opened this issue 11 years ago • 3 comments

Add {read_concurrency, true} option to ETS table and lookup it directly, bypasing gen_server:call. This may be done without any API changes.

seriyps avatar Feb 11 '14 18:02 seriyps

Lookup directly...hm I wonder if someone running gettext in a distributed setting where the server only runs on a specific node? I don't remember how Klarna (a big user of gettext) does.

etnt avatar Feb 14 '14 13:02 etnt

I think, it may be optional, by setting flags in gettext_server's process dictionary like

key2str(Server, Key, Lang) ->
    case proplists:get_value(public_table, erlang:process_info(Server, dictionary)) of
        undefined ->
            gen_server:call(Server, ...);
        Tid ->
            ets:lookup(Tid, ...)
    end.

Which is quite fast and don't require any message-passing.

seriyps avatar Feb 14 '14 13:02 seriyps

I would be very cautious to add anything hidden under key2str/3 since it is really heavily called in large systems such as Klarnas. I don't like the proplists module at all, and doing a process_info call, involving another process, may have uncertain side effects (e.g being re-scheduled?).

etnt avatar Feb 14 '14 13:02 etnt