Use raise_notrace instead of raise to implement Hashtbl.replace.

This significantly improves the benchmark below:

  let ht = Hashtbl.create 100 in
  for x = 1 to 2500000 do
    Hashtbl.replace ht x ();
    Hashtbl.remove ht x
  done

(about 20% faster, still not as good as #328, which is about 35% faster
than trunk on this one)

In addition to the speedup, using raise_notrace should avoid destroying
the current stack trace when Hashtbl.replace is used in an exception
handler.
master
alainfrisch 2015-12-04 08:57:16 +01:00
parent 1c9e418b92
commit 66e864a53f
1 changed files with 2 additions and 2 deletions

View File

@ -158,7 +158,7 @@ let find_all h key =
let replace h key info =
let rec replace_bucket = function
| Empty ->
raise Not_found
raise_notrace Not_found
| Cons(k, i, next) ->
if compare k key = 0
then Cons(key, info, next)
@ -350,7 +350,7 @@ module MakeSeeded(H: SeededHashedType): (SeededS with type key = H.t) =
let replace h key info =
let rec replace_bucket = function
| Empty ->
raise Not_found
raise_notrace Not_found
| Cons(k, i, next) ->
if H.equal k key
then Cons(key, info, next)